package com.future.mayi.adapter;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.future.mayi.R;
import com.future.mayi.model.CourierInfoModel;

import java.util.List;

public class CourierInfoAdapter extends CommonAdapter<CourierInfoModel> {


    public CourierInfoAdapter(Context context, List<CourierInfoModel> objects) {
        super(context, R.layout.layout_courier_info_item, objects);
    }

    @Override
    public void convert(ViewHolder helper, CourierInfoModel item) {
        boolean isFirst = helper.getPosition() == 0;
        boolean isBottom = helper.getPosition() == (getCount() - 1);
        helper.getView(R.id.view_dian).setBackgroundResource(isFirst ? R.drawable.bg_courier_item_dian_f : R.drawable.bg_courier_item_dian_t);
        helper.getView(R.id.view_line_last).setVisibility((isFirst || isBottom) ? View.GONE : View.VISIBLE);
        helper.getView(R.id.view_line_first).setVisibility(isFirst ? View.VISIBLE : View.GONE);
        helper.getView(R.id.view_line_bottom).setVisibility(isBottom ? View.VISIBLE : View.GONE);
        helper.setText(R.id.tv_content, item.getAcceptStation());
        helper.setText(R.id.tv_time, item.getAcceptTime());
        ((TextView) helper.getView(R.id.tv_content)).setTextColor(mContext.getResources().getColor(isFirst ? R.color.text_colorfe7712 : R.color.text_color4));
        ((TextView) helper.getView(R.id.tv_time)).setTextColor(mContext.getResources().getColor(isFirst ? R.color.text_colorfe7712 : R.color.text_color8F));


    }
}
